package text111;

import javax.swing.text.AbstractDocument.LeafElement;

public class Solution18 {
	 public int maxProfit(int[] prices) {
		 int maxprofit = 0;
	        for (int i = 0; i < prices.length - 1; i++) {
	            for (int j = i + 1; j < prices.length; j++) {
	                int profit = prices[j] - prices[i];
	                if (profit > maxprofit) {
	                    maxprofit = profit;
	                }
	            }
	        }
	        return maxprofit;
	    }
}
